package cn.tedu.store.annotation;

import java.lang.reflect.Method;

public class ParseAnn {

	public static void main(String[] args) {
		
		try {
			//1.使用类加载器加载类
			Class c = Class.forName("cn.tedu.store.annotation.Baba");
			//2.找到类上面的注解
			boolean isExist = c.isAnnotationPresent(Description.class);
			if(isExist) {
				//3.拿到注解实例
				Description d = (Description)c.getAnnotation(Description.class);
				System.out.println(d.author());
			}
			Method[] m = c.getMethods();
			for(Method me:m) {
				boolean isMExist = me.isAnnotationPresent(Description.class);
				if(isMExist) {
					Description d = me.getAnnotation(Description.class);
					System.out.println(d.author());
				}
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

	}

}
